package com.smart.primary.util.creat;



import java.io.PrintStream;
import java.util.List;

public class CreatDao {
	public static void creat(List<Class<?>> cla) {
		try {
			PrintStream ps;
			for (Class<?> cc : cla) {
				ps = new PrintStream(Creat.getPath(Creat.dao)+cc.getSimpleName()+Creat.mapper+".java");
				System.setOut(ps);//把创建的打印输出流赋给系统。即系统下次向 ps输出
				getDao1(cc);//输出的内容
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public static void getDao(Class<?> cc) {
		String str = cc.getName();
		str = StrUtil.subIndOf(str,".",-2);
		str += "."+StrUtil.toLowerOne(Creat.dao)+";";
		System.out.println("package "+str+"\r\n");

		System.out.println(
				"import org.springframework.data.domain.Page;\r\n" +
				"import org.springframework.data.domain.Pageable;\r\n" +
				"import org.springframework.data.jpa.repository.JpaRepository;\r\n" +
				"\r\n");

		System.out.println(
				"public interface "+cc.getSimpleName()+"Repository extends JpaRepository<"+cc.getSimpleName()+",String> {\r\n");

		System.out.println(
				"    "+cc.getSimpleName()+" findByUuid(String uuid);\r\n" +
				"    Page<"+cc.getSimpleName()+"> findBy...Like(String keyword, Pageable pageable);\r\n}");
	}

	public static void getDao1(Class<?> cc) {
		System.out.println(
				"package "+Creat.pack+"."+StrUtil.toLowerOne(Creat.dao)+";\r\n" +
				"\r\n" +
				"import com.smart.buss.vo."+cc.getSimpleName()+";\r\n" +
				"import com.smart.primary.common.common.IBase;\r\n" +
				"\r\n" +
				"public interface "+cc.getSimpleName()+"Mapper extends IBase<"+cc.getSimpleName()+"> {\r\n" +
				"\r\n" +
				"}");
	}
}
